@extends('admin.app')

@section('breadcrumb')
    <div class="bg-light lter b-b wrapper-md">
        <ol class="breadcrumb bg-light lter m-n no-padder">
            <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
            <li>业务管理</li>
            <li class="active">用户管理</li>
        </ol>
    </div>
@endsection

@section('content')
    <div class="panel panel-default">
        <div class="panel-heading font-bold">
            用户列表列表
        </div>
        <div class="row wrapper">
            <div class="col-sm-8">
                <form class="form-horizontal" method="get"
                      action="{{ admin_action('Business\OrganizationalUserManagementController@index') }}">
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="control-label col-sm-4">用户名:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="欲查询的用户名" name="username"
                                           value="{{ $query['username'] }}"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="control-label col-sm-4">企业名称:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="欲查询的企业名称" name="company_name"
                                           value="{{ $query['company_name'] }}"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                <label class="control-label col-sm-4">审核状态:</label>
                                <div class="col-sm-8">
                                    <select name="status" class="form-control select2">
                                        <option value="">
                                            请选择审核状态
                                        </option>
                                        <option value="SUCCESS" {{ $query['status']=='SUCCESS'?'selected=selected':'' }}>
                                            审核成功
                                        </option>
                                        <option value="PROCESSING" {{ $query['status']=='PROCESSING'?'selected=selected':'' }}>
                                            审核中
                                        </option>
                                        <option value="FAILED" {{ $query['status']=='FAILED'?'selected=selected':'' }}>
                                            审核失败
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-1 text-left">
            <span class="input-group-btn">
              <button class="btn btn-sm btn-default" type="submit">查询</button>
            </span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-4 text-right text-center-xs">
                <a class="btn m-b-xs btn-sm btn-default btn-addon"
                   href="{{ admin_action('Business\OrganizationalUserManagementController@create') }}">
                    <i class="fa fa-plus"></i>新增一个用户
                </a>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                <tr>
                    <th>企业用户标识</th>
                    <th>用户名</th>
                    <th>企业名称</th>
                    <th>机构简码</th>
                    <th>经纪人分润比例</th>
                    <th>激活状态</th>
                    <th>创建时间</th>
                </tr>
                </thead>
                <tbody>
                @forelse ($users as $user)
                    <tr>
                        <td>{{ $user->identity_id }}</td>
                        <td>{{ $user->username }}</td>
                        <td>{{ $user->company_name }}</td>
                        <td>{{ $user->code}}</td>
                        <td>{{ $user->profit_ratio}}</td>
                        <td>
                            @if($user->status == 'PROCESSING')
                                <label class="text-info">审核中</label>
                            @elseif($user->status == 'SUCCESS')
                                <label class="text-primary">审核成功</label>
                            @elseif($user->status == 'FAILED')
                                <label class="text-warning">审核失败</label>
                            @else
                                <label class="text-danger">未知状态</label>
                            @endif
                        </td>
                        <td>{{ $user->created_at }}</td>
                        <td>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@show', [$user]) }}"
                               data-toggle="tooltip" title="机构详情">
                                <i class="fa fa-info"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@setPayPassword', [$user]) }}"
                               data-toggle="tooltip" title="设置支付密码">
                                <i class="fa fa-lock"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@setAgentInfo', [$user]) }}"
                               data-toggle="tooltip" title="设置经办人信息">
                                <i class="fa fa-user"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@deptList', [$user]) }}"
                               data-toggle="tooltip" title="查询下属部门">
                                <i class="fa fa-sitemap"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@queryMemberInfos', [$user]) }}"
                               data-toggle="tooltip" title="查询余额信息">
                                <i class="fa fa-leaf"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@edit', [$user]) }}"
                               data-toggle="tooltip" title="编辑该用户">
                                <i class="fa fa-pencil"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@brokerDncomeDistribution', [$user]) }}"
                               data-toggle="tooltip" title="配置分润比例">
                                <i class="fa fa-bar-chart"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Business\OrganizationalUserManagementController@orgToUser', [$user]) }}"
                               data-toggle="tooltip" title="同步用户信息">
                                <i class="glyphicon glyphicon-refresh"></i>
                            </a>
                           <!--  <form class="inline"
                                  action="{{ admin_action('Business\OrganizationalUserManagementController@destroy', [$user]) }}"
                                  method="post">
                                {{ csrf_field() }}
                                {{ method_field('DELETE') }}
                                <button type="button" data-swal-role="delete-confirm" data-swal-title="温馨提示"
                                        data-swal-text="您将删除机构用户 <{{ empty($user->userInfo->name)?$user->username:$user->userInfo->name }}>   "
                                        class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除用户">
                                    <i class="fa fa-trash-o"></i>
                                </button>
                            </form> -->
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="3" class="text-center">没有找到用户记录</td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="panel-footer">
            <div class="row">
                <div class="col-sm-12 text-right text-center-xs">
                    {!! $links !!}
                </div>
            </div>
        </div>
    </div>
@endsection